/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import core.Doctor;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JTable;

/**
 *
 * @author Marcin
 */
public class PopUpMenuTerms extends JPopupMenu{
    private JMenuItem itTerm;
    private Doctor d;
    PopUpMenuTerms(final Doctor d,final JCalendar cal) {
        itTerm = new JMenuItem("Dodaj termin");
        this.d = d;
        itTerm.addMouseListener(new MouseAdapter(){
            @Override
            public void mouseReleased(MouseEvent e) {
                cal.addEvent(JCalendar.CellType.AVAILABLE);
                int col[] = cal.getCalendar().getSelectedColumns();
                for(int c : col){
                    if(c!=0) {
                        d.addTerm(cal.getSelectedDateStart(c),cal.getSelectedDateEnd(c),cal.getCalendar().getColumnName(c).toString());
                    }
                }
                cal.repaint();
            }
        });
        add(itTerm);
    }
}
